
# include "dfxDllMain.h"

namespace DFX
{
    Editor *gEditor = NULL;

    Int32 EditorMain(UInt32 topHandle, UInt32 topWidth, UInt32 topHeight,
        UInt32 leftHandle, UInt32 leftWidth, UInt32 leftHeight,
        UInt32 rightHandle, UInt32 rightWidth, UInt32 rightHeight,
        UInt32 perspHandle, UInt32 perspWidth, UInt32 perspHeight)
    {        
        std::vector<WINDOW_PARAMETERS*> params;

        for (UInt32 i = 0; i < NUM_WINDOWS; i++)
            params.push_back(new WINDOW_PARAMETERS());

        params[0]->Hwnd = topHandle;
        params[0]->Width = topWidth;
        params[0]->Height = topHeight;
        params[0]->ColorBits = 32;
        params[0]->DepthBits = 24;

        params[1]->Hwnd = leftHandle;
        params[1]->Width = leftWidth;
        params[1]->Height = leftHeight;
        params[1]->ColorBits = 32;
        params[1]->DepthBits = 24;

        params[2]->Hwnd = rightHandle;
        params[2]->Width = rightWidth;
        params[2]->Height = rightHeight;
        params[2]->ColorBits = 32;
        params[2]->DepthBits = 24;

        params[3]->Hwnd = perspHandle;
        params[3]->Width = perspWidth;
        params[3]->Height = perspHeight;
        params[3]->ColorBits = 32;
        params[3]->DepthBits = 24;

        gEditor = new Editor(".");

        if (DFX_FAILED(gEditor->Initialize(params)))
        {
            fprintf(stderr, "Error- editor initalization failed");
            return -1;
        }

        for (UInt32 i = 0; i < NUM_WINDOWS; i++)
            SAFE_DELETE(params[i]);

        params.clear();

        return 0;
    }

    void EditorRender(UInt32 index)
    {
        gEditor->Render(index);
    }

    void EditorDestroy()
    {
        SAFE_DELETE(gEditor);
    }

    void EditorWndProc(UInt32 handle, UInt32 msg, UInt32 wParam, UInt32 lParam)
    {
    }

    void EditorSwapBuffers(UInt32 index)
    {
        gEditor->GetWindow(index)->SwapBuffers();
    }
}